package java04;

class Exception05 extends Exception{
    public Exception05() {
        super();//调用父类的无参构造
    }

    public Exception05(String message) {
        super(message);//调用父类的有参构造
    }
}
public class ExceptionTest01 {
    public static int divide(int x,int y) throws Exception05{
        if(y == 0){
            //使用throw关键字声明异常对象
            throw new Exception05("除数是0");
        }
        int result = x / y;
        return result;
    }
    public static void main(String[] args){
        try{
            int result  =divide(9,0);
            System.out.println(result);
        }catch (Exception05 e){
            System.out.println("捕获的异常信息为：" + e.getMessage());
        }
    }
}
